import moment from "moment";
const isEmpty =(str)=>{
  if(str == null || str == "" || str == undefined){
    return true;
  }
  return false;
}


const getToken=()=>{

    let userInfoJson  = localStorage.getItem("userInfo");
    const token = userInfoJson ? JSON.parse(userInfoJson).token : "";
    return token;
}



const formatDate=(timestamp, format = 'YYYY-MM-DD hh:mm:ss')=>{
  const date = new Date(timestamp);
  const year = date.getFullYear();
  const month = String(date.getMonth() + 1).padStart(2, '0'); // 月份从0开始，所以要加1
  const day = String(date.getDate()).padStart(2, '0');
  const hours = String(date.getHours()).padStart(2, '0');
  const minutes = String(date.getMinutes()).padStart(2, '0');
  const seconds = String(date.getSeconds()).padStart(2, '0');
   return format
    .replace('YYYY', year)
    .replace('MM', month)
    .replace('DD', day)
    .replace('hh', hours)
    .replace('mm', minutes)
    .replace('ss', seconds);

}


const formatChineseDate=()=>{
 const date = new Date(new Date().getTime());
 const weekDays = ['星期日', '星期一', '星期二', '星期三', '星期四', '星期五', '星期六'];
 const weekDay = weekDays[date.getDay()];
    // 返回结果
    return weekDay;

}


export default{
    isEmpty,formatDate,formatChineseDate

}
